package com.gjzt.business.bid.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eastdigit.servlet.RequestAttribute;
import com.eastdigit.servlet.Response;
import com.eastdigit.servlet.ReqBean;
import com.gjzt.business.bid.service.BiddingService;

@Controller
@RequestMapping(value = "/bid")
public class BiddingController {

    @Autowired
    private BiddingService biddingService;

    /**
     * 查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/query")
    @ResponseBody
    public JSONObject queryAdBidding(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.findAdBidding(reqBean));
    }

    /**
     * 查询竞价记录
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/queryBidRecord")
    @ResponseBody
    public JSONObject queryBidRecord(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.queryBidRecord(reqBean));
    }

    /**
     * 获取车辆资源树形结构数据
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/getResourceOfBusTree")
    @ResponseBody
    public JSONObject getResourceOfBusTree(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.getResourceOfBusTree(reqBean));
    }

    /**
     * 获取车辆资源树形结构数据
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/getResourceOfStopTree")
    @ResponseBody
    public JSONObject getResourceOfStopTree(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.getResourceOfStopTree(reqBean));
    }
    
    
    
    /**
     * 查询竞价包含的资源(按资源类型分类)
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/getBidResourceGroupByTypes")
    @ResponseBody
    public JSONObject getBidResourceTypes(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.getBidResourceGroupByTypes(reqBean));
    }
    
    /**
     * 添加车辆对应的资源
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/addResourceOfBill")
    @ResponseBody
    public JSONObject addResourceOfBill(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        biddingService.addResourceOfBill(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 添加
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public JSONObject addAdBidding(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.addAdBidding(reqBean));
    }
    
    /**
     * 发布
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/publishBid")
    @ResponseBody
    public JSONObject publishBid(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        biddingService.publishBid(reqBean);
        return Response.responseSuccess();
    }
    
    /**
     * 修改
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public JSONObject updateAdBidding(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.updateAdBidding(reqBean));
    }
    /**
     * 删除
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public JSONObject removeAdBidding(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        biddingService.removeAdBidding(reqBean);
        return Response.responseSuccess();
    }
    
    /**
     * 添加
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/verifyResourceDate")
    @ResponseBody
    public JSONObject verifyResourceDate(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(biddingService.verifyResourceDate(reqBean));
    }
    
    //TODO 其他功能
}